@tailwind base;
@tailwind components;
@tailwind utilities;

:root {
  --foreground: 20 14.3% 4.1%;
  --muted: 60 4.8% 95.9%;
  --muted-foreground: 25 5.3% 44.7%;
  --popover: 0 0% 100%;
  --popover-foreground: 20 14.3% 4.1%;
  --card: 0 0% 100%;
  --card-foreground: 20 14.3% 4.1%;
  --border: 20 5.9% 90%;
  --input: 20 5.9% 90%;
  --primary: 207 90% 54%;
  --primary-foreground: 211 100% 99%;
  --secondary: 30 84% 54%; /* Changed from red (0) to orange (30) */
  --secondary-foreground: 60 9.1% 97.8%;
  --accent: 60 4.8% 95.9%;
  --accent-foreground: 24 9.8% 10%;
  --destructive: 0 84.2% 60.2%;
  --destructive-foreground: 60 9.1% 97.8%;
  --ring: 20 14.3% 4.1%;
  --radius: 0.5rem;
}

@layer base {
  * {
    @apply border-border;
  }
}

/* Video Player Styles */
.video-player {
  position: relative;
  width: 100%;
  background-color: #000;
  overflow: hidden;
  border-radius: 0.5rem;
}

.video-controls {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
  padding: 1rem;
  display: flex;
  flex-direction: column;
}

.video-current-time {
  color: #fff;
  font-weight: 500;
}

.video-progress {
  position: relative;
  height: 4px;
  background-color: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  margin-bottom: 1rem;
}

.video-progress-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  background-color: hsl(var(--primary));
  border-radius: 2px;
}

.video-scrubber {
  position: absolute;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  background-color: white;
  border-radius: 50%;
  top: -4px;
}

/* Play/Pause indicator for video player */
.video-player-container {
  position: relative;
  overflow: hidden;
}

.play-pause-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 70px;
  height: 70px;
  border-radius: 50%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 20;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: none;
  background-position: center;
  background-repeat: no-repeat;
}

.play-icon {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='36' height='36' fill='white'%3E%3Cpath d='M8 5v14l11-7z'/%3E%3C/svg%3E");
}

.pause-icon {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='36' height='36' fill='white'%3E%3Cpath d='M6 19h4V5H6v14zm8-14v14h4V5h-4z'/%3E%3C/svg%3E");
}

/* Only show play/pause indicator on hover */
.video-player-container:hover .play-pause-indicator {
  opacity: 1;
}

/* Timeline Styles */
.timeline-scroll-container {
  height: 6rem;
  border-radius: 0.375rem;
  overflow-x: auto;
  overflow-y: hidden;
  margin-bottom: 0.75rem;
  background-color: #eee; /* Very light gray background */
  position: relative;
}

.timeline-container {
  position: relative;
  background-color: #eee; /* Very light gray background */
  height: 6rem;
  width: 100%;
  cursor: pointer;
  transition: width 0.3s ease;
}

.timeline-marker {
  position: absolute;
  top: -10px;
  height: calc(100% + 10px);
  width: 2px;
  background-color: red;
  z-index: 100; /* Highest z-index to stay on top of everything */
  pointer-events: none; /* Allow clicks to pass through to segments underneath */
  box-shadow: 0 0 4px rgba(255, 0, 0, 0.5); /* Add subtle glow effect */
}

.trim-line-marker {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background-color: rgba(0, 123, 255, 0.9); /* Primary blue color */
  z-index: 10;
}

.trim-handle {
  width: 8px;
  background-color: rgba(108, 117, 125, 0.9); /* Secondary gray color */
  position: absolute;
  top: 0;
  bottom: 0;
  cursor: ew-resize;
  z-index: 15;
}

.trim-handle.left {
  left: -4px;
}

.trim-handle.right {
  right: -4px;
}

.split-point {
  position: absolute;
  width: 2px;
  background-color: rgba(108, 117, 125, 0.9); /* Secondary gray color */
  top: 0;
  bottom: 0;
  z-index: 5;
}

/* Clip Segment styles */
.clip-segment {
  position: absolute;
  height: 95%;
  top: 0;
  border-radius: 4px;
  background-size: cover;
  background-position: center;
  background-blend-mode: soft-light;
  /* Border is now set in the color-specific rules */
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  cursor: grab;
  user-select: none;
  transition:
    box-shadow 0.2s,
    transform 0.1s;
  /* Original z-index for stacking order based on segment ID */
  z-index: 15;
}

/* No background colors for segments, just borders with 2-color scheme */
.clip-segment:nth-child(odd),
.segment-color-1,
.segment-color-3,
.segment-color-5,
.segment-color-7 {
  background-color: transparent;
  border: 2px solid rgba(0, 123, 255, 0.9); /* Blue border */
}
.clip-segment:nth-child(even),
.segment-color-2,
.segment-color-4,
.segment-color-6,
.segment-color-8 {
  background-color: transparent;
  border: 2px solid rgba(108, 117, 125, 0.9); /* Gray border */
}

.clip-segment:hover {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transform: translateY(-1px);
  filter: brightness(1.1);
}

.clip-segment:active {
  cursor: grabbing;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
  transform: translateY(0);
}

.clip-segment.selected {
  border-width: 3px; /* Make border thicker instead of changing color */
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  z-index: 25;
  filter: brightness(1.2);
}

.clip-segment-info {
  background-color: rgba(226, 230, 234, 0.9); /* Light gray background */
  color: #000000; /* Pure black text */
  padding: 6px 8px;
  font-size: 0.7rem;
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  border-radius: 4px 4px 0 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.clip-segment-name {
  font-weight: bold;
  color: #000000; /* Pure black text */
}

.clip-segment-time {
  font-size: 0.65rem;
  color: #000000; /* Pure black text */
}

.clip-segment-duration {
  font-size: 0.65rem;
  color: #000000; /* Pure black text */
  background: rgba(179, 217, 255, 0.4); /* Light blue background */
  padding: 1px 4px;
  border-radius: 2px;
  display: inline-block;
  margin-top: 2px;
}

.clip-segment-handle {
  position: absolute;
  width: 8px;
  top: 0;
  bottom: 0;
  background-color: rgba(108, 117, 125, 0.9); /* Secondary gray color */
  cursor: ew-resize;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
}

.clip-segment-handle::after {
  content: "↔";
  color: white;
  font-size: 12px;
  text-shadow: 0 0 2px rgba(0, 0, 0, 0.8);
}

.clip-segment-handle.left {
  left: 0;
}

.clip-segment-handle.right {
  right: 0;
}

.clip-segment-handle:hover {
  background-color: rgba(0, 123, 255, 0.9); /* Primary blue color */
  width: 10px;
}

/* Zoom Slider */
input[type="range"] {
  -webkit-appearance: none;
  height: 6px;
  background: #e0e0e0;
  border-radius: 3px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  height: 16px;
  width: 16px;
  border-radius: 50%;
  background: rgba(0, 123, 255, 0.9); /* Primary blue color */
  cursor: pointer;
}

/* Tooltip styles */
[data-tooltip] {
  position: relative;
  cursor: pointer;
}

[data-tooltip]::before {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-bottom: 8px;
  background-color: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 5px 10px;
  border-radius: 4px;
  font-size: 0.8rem;
  white-space: nowrap;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.2s,
    visibility 0.2s;
  pointer-events: none;
}

[data-tooltip]::after {
  content: "";
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border-width: 5px;
  border-style: solid;
  border-color: rgba(0, 0, 0, 0.8) transparent transparent transparent;
  margin-bottom: 0px;
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 0.2s,
    visibility 0.2s;
  pointer-events: none;
}

/* Only show tooltips on devices with mouse hover capability */
@media (hover: hover) and (pointer: fine) {
  [data-tooltip]:hover::before,
  [data-tooltip]:hover::after {
    opacity: 1;
    visibility: visible;
  }
}

/* Hide button tooltips (simple hover labels) on touch devices */
@media (pointer: coarse) {
  [data-tooltip]::before,
  [data-tooltip]::after {
    display: none !important;
    content: none !important;
    opacity: 0 !important;
    visibility: hidden !important;
    pointer-events: none !important;
  }
}

/* Fix for buttons with disabled state */
button[disabled][data-tooltip]::before,
button[disabled][data-tooltip]::after {
  opacity: 0.5;
}

/* Custom tooltip for action buttons - completely different approach */
.tooltip-action-btn {
  position: relative;
}

.tooltip-action-btn[data-tooltip]::before,
.tooltip-action-btn[data-tooltip]::after {
  /* Reset standard tooltip styles first */
  opacity: 0;
  visibility: hidden;
  position: absolute;
  pointer-events: none;
  transition: all 0.3s ease;
}

.tooltip-action-btn[data-tooltip]::before {
  content: attr(data-tooltip);
  background-color: rgba(0, 0, 0, 0.8);
  color: white;
  font-size: 12px;
  padding: 4px 8px;
  border-radius: 3px;
  white-space: nowrap;

  /* Position below the button */
  bottom: -35px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
}

.tooltip-action-btn[data-tooltip]::after {
  content: "";
  border-width: 5px;
  border-style: solid;
  border-color: transparent transparent rgba(0, 0, 0, 0.8) transparent;

  /* Position the arrow */
  bottom: -15px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9999;
}

/* Only show tooltips on devices with mouse hover capability */
@media (hover: hover) and (pointer: fine) {
  .tooltip-action-btn:hover[data-tooltip]::before,
  .tooltip-action-btn:hover[data-tooltip]::after {
    opacity: 1;
    visibility: visible;
  }
}

/* Ensure tooltip container has proper space */

/* Segment tooltip styles */
.segment-tooltip {
  background-color: rgba(179, 217, 255, 0.95); /* Light blue color */
  color: #000000; /* Pure black text */
  border-radius: 4px;
  padding: 6px; /* Regular padding now that we have custom tooltips */
  min-width: 140px; /* Increased width to accommodate the new delete button */
  z-index: 1000; /* Increased z-index */
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}

.segment-tooltip::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-top: 6px solid rgba(179, 217, 255, 0.95); /* Light blue color */
}

.tooltip-time {
  font-size: 0.85rem;
  font-weight: bold;
  text-align: center;
  margin-bottom: 6px;
  color: #000000; /* Pure black text */
}

.tooltip-actions {
  display: flex;
  justify-content: space-between;
  gap: 5px;
  position: relative;
}

.tooltip-action-btn {
  background-color: rgba(0, 123, 255, 0.2); /* Light blue background */
  border: none;
  border-radius: 3px;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 6px;
  transition: background-color 0.2s;
  min-width: 20px !important;
}

.tooltip-action-btn:hover {
  background-color: rgba(0, 123, 255, 0.4); /* Slightly darker on hover */
}

.tooltip-action-btn svg {
  width: 100%;
  height: 100%;
  stroke: currentColor;
}

/* Adjust for the hand icons specifically */
.tooltip-action-btn.set-in svg,
.tooltip-action-btn.set-out svg {
  width: 100%;
  height: 100%;
  margin: 0 auto;
  fill: currentColor;
  stroke: none;
}

/* Empty space tooltip styling */
.empty-space-tooltip {
  background-color: white;
  border-radius: 6px;
  box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.15);
  padding: 8px;
  z-index: 50;
  min-width: 120px;
  text-align: center;
  position: relative;
}

.empty-space-tooltip::after {
  content: "";
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 8px 8px 0;
  border-style: solid;
  border-color: white transparent transparent;
}

.tooltip-action-btn.new-segment {
  width: auto;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 5px;
}

.tooltip-btn-text {
  font-size: 0.8rem;
  white-space: nowrap;
  color: #000000; /* Pure black text */
}

.icon-new-segment {
  width: 20px;
  height: 20px;
}

/* Zoom dropdown styling */
.zoom-dropdown-container {
  position: relative;
}

.zoom-button {
  display: flex;
  align-items: center;
  gap: 6px;
  background-color: rgba(108, 117, 125, 0.8);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 8px 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
}

.zoom-button:hover {
  background-color: rgba(108, 117, 125, 1);
}

.zoom-dropdown {
  background-color: white;
  border-radius: 4px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
  max-height: 300px;
  overflow-y: auto;
}

.zoom-option {
  padding: 8px 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 5px;
}

.zoom-option:hover {
  background-color: rgba(0, 123, 255, 0.1);
}

.zoom-option.selected {
  background-color: rgba(0, 123, 255, 0.2);
  font-weight: 500;
}

/* Save buttons styling */
.save-button,
.save-copy-button,
.save-segments-button {
  background-color: rgba(0, 123, 255, 0.8);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 8px 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.2s;
}

.save-button:hover,
.save-copy-button:hover {
  background-color: rgba(0, 123, 255, 1);
}

.save-copy-button {
  background-color: rgba(108, 117, 125, 0.8);
}

.save-copy-button:hover {
  background-color: rgba(108, 117, 125, 1);
}

/* Time navigation input styling */
.time-nav-label {
  font-weight: 500;
  font-size: 0.9rem;
}

.time-input {
  padding: 6px 10px;
  border-radius: 4px;
  border: 1px solid #ccc;
  width: 150px;
  font-family: monospace;
}

.time-button-group {
  display: flex;
  gap: 5px;
}

.time-button {
  background-color: rgba(108, 117, 125, 0.8);
  color: white;
  border: none;
  border-radius: 4px;
  padding: 6px 8px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: background-color 0.2s;
}

.time-button:hover {
  background-color: rgba(108, 117, 125, 1);
}

/* Timeline navigation and zoom controls responsiveness */
.timeline-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap; /* Allow wrapping on smaller screens */
  padding: 12px;
  background-color: #f5f5f5;
  border-radius: 6px;
  margin-top: 15px;
}

.time-navigation {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.controls-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Media queries for responsive design */
@media (max-width: 768px) {
  .timeline-controls {
    flex-direction: column;
    align-items: flex-start;
    gap: 15px;
  }

  .controls-right {
    margin-top: 10px;
    width: 100%;
    justify-content: flex-start;
    text-align: center;
    align-items: center;
    justify-content: center;
  }
}

/* Timeline header styling */
.timeline-header {
  display: flex;
  align-items: center;
  gap: 20px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.timeline-title {
  font-weight: bold;
  margin-right: 20px;
}

.timeline-title-text {
  font-size: 1.1rem;
}

.current-time,
.duration-time {
  white-space: nowrap;
}

.time-code {
  font-family: monospace;
  font-weight: 500;
}

@media (max-width: 480px) {
  .timeline-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
  }

  .time-navigation {
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .time-button-group {
    width: 100%;
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
  }

  .controls-right {
    flex-wrap: wrap;
    gap: 8px;
  }

  .save-button,
  .save-copy-button {
    margin-top: 8px;
    width: 100%;
  }

  .zoom-dropdown-container {
    width: 100%;
  }

  .zoom-button {
    width: 100%;
    justify-content: center;
  }
}
